package com.nefu.huiyi.service.impl;

import com.nefu.huiyi.dto.DepartmentStatsDTO;
import com.nefu.huiyi.repository.DepartmentStatsRepository;
import com.nefu.huiyi.service.DepartmentService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@RequiredArgsConstructor
public class DepartmentServiceImpl implements DepartmentService {

    private final DepartmentStatsRepository repository;

    @Override
    public Map<String, Integer> getDepartmentDistribution() {
        return repository.countDoctorsByDepartment()
                .stream()
                .collect(Collectors.toMap(
                        DepartmentStatsDTO::getDepartmentName,
                        DepartmentStatsDTO::getDoctorCount
                ));
    }
}